<html>
<head><meta charset="utf-8"><title>Moving `#[cfg(test)]` modules into a sepa… compiler-team#344 · t-compiler/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/index.html">t-compiler/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html">Moving `#[cfg(test)]` modules into a sepa… compiler-team#344</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206804794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206804794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206804794">(Aug 13 2020 at 11:43)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/compiler-team/issues/344">#344</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="206805077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206805077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206805077">(Aug 13 2020 at 11:47)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="204346">@Ashley Mannix</span> as reviewer of <a href="https://github.com/rust-lang/rust/pull/75108">https://github.com/rust-lang/rust/pull/75108</a><br>
cc <span class="user-mention" data-user-id="116122">@simulacrum</span> do you want to be a mentor of this proposal?</p>



<a name="206805193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206805193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206805193">(Aug 13 2020 at 11:48)</a>:</h4>
<p>IMO we don't need an MCP for this, we can just do it. But I'm not opposed to reviewing PRs finishing this (IIRC <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> has done this for several compiler crates already).</p>



<a name="206806858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206806858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206806858">(Aug 13 2020 at 12:09)</a>:</h4>
<p>One point I’d have here is that it be nice to make the current scheme of the cfg in the file better as a <em>lot</em> of existing code does it outside of the stdlib.</p>



<a name="206815390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206815390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206815390">(Aug 13 2020 at 13:38)</a>:</h4>
<p>I feel like I'm missing something, you still have to recompile <code>std</code> with <code>--cfg test</code> to have the tests included.</p>



<a name="206816470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206816470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206816470">(Aug 13 2020 at 13:47)</a>:</h4>
<p>iirc the compiler doesn't emit the <a href="http://test.rs">test.rs</a> into dep-info for the non-test compilation, which means that you don't recompile the library <em>twice</em> with this approach, but I forget how exactly it works</p>



<a name="206821470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206821470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206821470">(Aug 13 2020 at 14:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344/near/206805193">said</a>:</p>
<blockquote>
<p>IMO we don't need an MCP for this, we can just do it.</p>
</blockquote>
<p>I would like to have a consensus about moving <code>cfg(test)</code> tests to files.<br>
So we don't have to discuss whether to move tests in each PR.</p>



<a name="206821578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206821578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206821578">(Aug 13 2020 at 14:30)</a>:</h4>
<p>hm well I don't think there was any opposition</p>



<a name="206821596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206821596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206821596">(Aug 13 2020 at 14:30)</a>:</h4>
<p>but mcp doesn't seem bad I guess to re-affirm that</p>



<a name="206822411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206822411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206822411">(Aug 13 2020 at 14:37)</a>:</h4>
<p>I mean moving tests is kind of big changes (in diff) and has disadvantage in <code>git blame</code>.<br>
So reviewer may feel hesitant to accept PR like that.</p>



<a name="206822531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206822531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206822531">(Aug 13 2020 at 14:38)</a>:</h4>
<p>I'm not too worried about large PRs that are <em>just</em> moving things around</p>



<a name="206849531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206849531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206849531">(Aug 13 2020 at 18:08)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="492">@T-compiler</span>: Proposal <a href="https://github.com/rust-lang/compiler-team/issues/344#issuecomment-673630248">#344</a> has been seconded, and will be approved in 10 days if no objections are raised.</p>



<a name="206849603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206849603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206849603">(Aug 13 2020 at 18:09)</a>:</h4>
<p>This is already done for all crates <em>except</em> for <code>std</code>, which is whitelisted in <code>tidy</code>.</p>



<a name="206849926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206849926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206849926">(Aug 13 2020 at 18:12)</a>:</h4>
<p>I didn't migrate <code>std</code> in <a href="https://github.com/rust-lang/rust/issues/63207">#63207</a> because it contained a lot of tests, needed platform-specific testing, and was maintained by the library team.</p>



<a name="206849950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206849950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206849950">(Aug 13 2020 at 18:13)</a>:</h4>
<p>It would be great if someone could finish this work now.</p>



<a name="206850000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206850000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206850000">(Aug 13 2020 at 18:13)</a>:</h4>
<p>Relevant tidy check - <a href="https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/unit_tests.rs">https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/unit_tests.rs</a></p>



<a name="206865946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206865946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206865946">(Aug 13 2020 at 20:22)</a>:</h4>
<p>Why shouldn’t every Rust crate ever follow suit here? What makes the standard library different?</p>



<a name="206866018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206866018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206866018">(Aug 13 2020 at 20:22)</a>:</h4>
<p>AFAIK all crates should do this, given current compiler/cargo limitations</p>



<a name="206882338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206882338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206882338">(Aug 13 2020 at 23:08)</a>:</h4>
<p>I was afraid you’d say that. Do we have any sense of how to fix those limitations? Adding tests in this way has been the <em>de-facto</em> recommendation since Rust 1.0.</p>



<a name="206889788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206889788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206889788">(Aug 14 2020 at 01:21)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> to be clear, the difference is between <code>#[cfg(test)] mod foo { ... }</code> and <code>#[cfg(test)] mod foo;</code>, both of which seem pretty canonical to me. It is true that the first option is in some sense more ergonomic (and recommended, e.g., cargo new --lib generates it), though.</p>
<p>I think fixing this basically isn't possible given the current file-based interface layer between rustc and Cargo; I am not aware of build systems that operate on a more granular level, but perhaps they exist. We could make rustc emit some more detailed information that isolated cfg-removed code as "not important" or Cargo could have a "quick run" feature for rustc where we pass in a hash that makes rustc exit early if, for example, the parsed (and expanded) crate is not different. Maybe incremental will eventually mean that the point here is moot, as recompiling will be sufficiently instant that it won't be a problem, but I think this is not going to be true for a long while -- and perhaps never.</p>
<p>The primary problem at least for most crates is not in the <em>individual</em> case of recompiling the library when running cargo test, but the fact that said recompilation forces Cargo to recompile all downstream crates too.</p>
<p>I guess an alternative is that we get reproducible builds to 100% and incremental far enough to where the recompilation of the library gives cargo an identical binary which it can then say "hey skip recompiling things depending on this".</p>



<a name="206892066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206892066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206892066">(Aug 14 2020 at 02:08)</a>:</h4>
<p>I read <a href="https://john-millikin.com/first-impressions-of-rust#single-crate-packaging">somewhere else</a> that bazel has capabilities to avoid rebuilding leaf files.</p>



<a name="206892080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206892080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206892080">(Aug 14 2020 at 02:08)</a>:</h4>
<p>But I've never used bazel so</p>



<a name="206893275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206893275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206893275">(Aug 14 2020 at 02:36)</a>:</h4>
<p>I'm not sure that is the case, but I also don't really know what the author meant by that - it seems like doing what I suggest wouldn't be possible without a Rust parser and I doubt they have that :)</p>



<a name="206928197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206928197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206928197">(Aug 14 2020 at 13:20)</a>:</h4>
<blockquote>
<p>the difference is between #[cfg(test)] mod foo { ... } and #[cfg(test)] mod foo;</p>
</blockquote>
<p>Good to hear, that was what I was envisioning.</p>
<blockquote>
<p>but the fact that said recompilation forces Cargo to recompile all downstream crates too.</p>
</blockquote>
<p>That sounds promising — I'm not seeing how that impacts a normal user with a single crate or even a workspace. Is this really just a problem for the complicated setup inherent to the compiler itself?</p>



<a name="206928302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206928302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206928302">(Aug 14 2020 at 13:22)</a>:</h4>
<p>I think workspaces would have the same problem</p>



<a name="206928324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206928324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206928324">(Aug 14 2020 at 13:22)</a>:</h4>
<p>if you modify any file in <code>rusoto_core</code> all 200 downstream crates now have to be recompiled</p>



<a name="206928343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206928343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206928343">(Aug 14 2020 at 13:22)</a>:</h4>
<p>and having tests inline means that changing tests counts as changing a source file</p>



<a name="206935781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206935781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206935781">(Aug 14 2020 at 14:38)</a>:</h4>
<p>Well, it still impacts people with just one crate, just less - you still invoke rustc twice if they're inline vs not</p>



<a name="206974429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206974429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206974429">(Aug 14 2020 at 19:57)</a>:</h4>
<p>I'm sure I could figure this out by issue spelunking, but  how is this not already trivially handled by incremental? Shouldn't the queries resolve to the exact same thing because all the changes happened in the cfg-gated section?</p>
<p>Or is the problem that we end up relinking, even without any compilation?</p>



<a name="206974960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206974960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206974960">(Aug 14 2020 at 19:59)</a>:</h4>
<blockquote>
<p>both of which seem pretty canonical to me</p>
</blockquote>
<p>Likewise in the "if I weren't so lazy" camp, I wonder what a search of github for <code>mod test;</code> vs <code>mod test {</code> would turn up. I'd pretty strongly expect inline test modules to be 90% of the case, if not more.</p>
<p>As a data point, it's what I've encouraged at every training session I've ever given.</p>



<a name="206975546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206975546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206975546">(Aug 14 2020 at 20:02)</a>:</h4>
<p>incremental is both not always on and doesn't give you zero-time -- in particular, we still parse and expand code at <em>least</em></p>



<a name="206975562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206975562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206975562">(Aug 14 2020 at 20:02)</a>:</h4>
<p>and incremental isn't perfect even on identical code</p>



<a name="206975584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206975584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206975584">(Aug 14 2020 at 20:02)</a>:</h4>
<p>much less when you've actually changed things just in cfg'd out code</p>



<a name="206976569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206976569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206976569">(Aug 14 2020 at 20:13)</a>:</h4>
<p>Moving the tests to a separate file doesn't give you zero time either, right? You still parse and expand all the non-test code to get to the <code>#[cfg(test)] mod test</code>, yeah?</p>



<a name="206977886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206977886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206977886">(Aug 14 2020 at 20:26)</a>:</h4>
<p>no</p>



<a name="206977898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/206977898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#206977898">(Aug 14 2020 at 20:26)</a>:</h4>
<p>if it's a separate file you only run rustc once</p>



<a name="207237174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207237174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207237174">(Aug 18 2020 at 08:54)</a>:</h4>
<p>I wonder if salsa will help improving this case.</p>



<a name="207237332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207237332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207237332">(Aug 18 2020 at 08:56)</a>:</h4>
<p>also, anybody want to take this issue after finishing proposal.<br>
If I take this issue, should I do it part-by-part or all-in-once?</p>



<a name="207237487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207237487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207237487">(Aug 18 2020 at 08:58)</a>:</h4>
<blockquote>
<p>I wonder if salsa will help improving this case.</p>
</blockquote>
<p>Not completely, "has this file changed?" is an important coars-grained granularity used by any build system. No matter how smart you make the compiler to be, it won't help you to determine if you should run the compiler in the first place.</p>



<a name="207237821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207237821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207237821">(Aug 18 2020 at 09:02)</a>:</h4>
<p>I agree, but will the compiler do less work and run faster?</p>



<a name="207238228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207238228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207238228">(Aug 18 2020 at 09:09)</a>:</h4>
<p>Yes, in a rather general sense that "improving incremental compilation will improve incremental compilation". I don't think there's anything specific to salsa per se -- it uses roughly the same red-green logic as the one already in the compiler.</p>



<a name="207275549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207275549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207275549">(Aug 18 2020 at 15:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344/near/206977898">said</a>:</p>
<blockquote>
<p>if it's a separate file you only run rustc once</p>
</blockquote>
<p>I'm totally missing something then. My understanding is that Cargo invokes <code>rustc src/lib.rs</code> which then has to parse that file to find all the modules to include them. </p>
<p>Is this after that step, when we've output the <code>.d</code> files? So in non-test mode the <code>.d</code> files don't include the separate <code>test.rs</code> files, but the <code>.d</code> files in test mode do?</p>



<a name="207275807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207275807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207275807">(Aug 18 2020 at 15:41)</a>:</h4>
<p>so the process if it's in a separate file is:</p>
<ul>
<li>edit test</li>
<li>run cargo test<br>
    * runs rustc --test <a href="http://foo.rs">foo.rs</a> --extern mycrate=libcrate.rlib</li>
</ul>
<p>so the process if it's in the same file is:</p>
<ul>
<li>edit test</li>
<li>run cargo test<br>
    * runs rustc <a href="http://lib.rs">lib.rs</a><br>
    * runs rustc --test <a href="http://lib.rs">lib.rs</a> --extern mycrate=libcrate.rlib</li>
</ul>



<a name="207275852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207275852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207275852">(Aug 18 2020 at 15:41)</a>:</h4>
<p>yeah there' separate .d for the <code>--test</code> run and not</p>



<a name="207275875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207275875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207275875">(Aug 18 2020 at 15:41)</a>:</h4>
<p>(<code>foo.rs</code>?)</p>



<a name="207276054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207276054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207276054">(Aug 18 2020 at 15:43)</a>:</h4>
<p>er, <a href="http://lib.rs">lib.rs</a></p>



<a name="207276259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207276259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207276259">(Aug 18 2020 at 15:44)</a>:</h4>
<p>And these processes are only for the second run of <code>cargo test</code>, right, as the first run Cargo has no knowledge about the files involved yet?</p>



<a name="207276359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207276359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207276359">(Aug 18 2020 at 15:45)</a>:</h4>
<p>And is the distinction <strong>powered</strong> by the <code>.d</code> files?</p>



<a name="207276447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207276447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207276447">(Aug 18 2020 at 15:46)</a>:</h4>
<p>hm well the first run would need to build the crate anyway</p>



<a name="207276467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207276467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207276467">(Aug 18 2020 at 15:46)</a>:</h4>
<p>but if you're after e.g. cargo build, then it doesn't need to</p>



<a name="207278083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207278083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207278083">(Aug 18 2020 at 15:59)</a>:</h4>
<p>Just to be clear, the first call to <code>rustc lib.rs</code> is only for integration tests and doctests.  If you run <code>cargo test --lib</code>, it won't do that step (which I think is relevant here, since we're talking about modifying unit tests).  There is no <code>--extern</code> for unit tests pointing to itself.</p>



<a name="207278466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207278466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207278466">(Aug 18 2020 at 16:01)</a>:</h4>
<p>ah, yes, that is a good point</p>



<a name="207278598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207278598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207278598">(Aug 18 2020 at 16:02)</a>:</h4>
<p>but <span class="user-mention" data-user-id="120518">@Eric Huss</span> that doesn't help speed up rebuild times in the case that your crate also has integration tests, right? Because you'll still wait for the crate to build twice unless passing --lib</p>



<a name="207278625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207278625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207278625">(Aug 18 2020 at 16:02)</a>:</h4>
<p>(obviously in parallel to some extent)</p>



<a name="207278992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207278992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207278992">(Aug 18 2020 at 16:06)</a>:</h4>
<p>Yea, in the context of <code>x.py</code>, AFAIK there doesn't exist that fine-grained control, so I think the original proposal is good for the standard library.  However, I'm not sure I entirely agree that it should be a general pattern everyone should necessarily use. I generally use targeted flags (like <code>--lib</code>), but maybe most people don't?</p>



<a name="207281038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207281038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207281038">(Aug 18 2020 at 16:20)</a>:</h4>
<p>I can't remember the names associated with them (flag itself) or the "target names" needed</p>



<a name="207281061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207281061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207281061">(Aug 18 2020 at 16:21)</a>:</h4>
<p>Maybe if we did the x.py thing of cargo test src/foo/test.rs</p>



<a name="207281108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207281108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207281108">(Aug 18 2020 at 16:21)</a>:</h4>
<p>(x.py would love to move that logic out to cargo so it works for more than just ui testing)</p>



<a name="207842264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/207842264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#207842264">(Aug 24 2020 at 13:24)</a>:</h4>
<p>almost 10 days since the proposal seconded<br>
I'd ask again:<br>
<span class="user-mention silent" data-user-id="209117">lzutao</span> <a href="#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344/near/207237332">said</a>:</p>
<blockquote>
<p>also, anybody want to take this issue after finishing proposal.<br>
If I take this issue, should I do it part-by-part or all-in-once?</p>
</blockquote>



<a name="208142426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/208142426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#208142426">(Aug 26 2020 at 20:13)</a>:</h4>
<p>This proposal has been accepted: <a href="https://github.com/rust-lang/compiler-team/issues/344">#344</a>.</p>



<a name="208220164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/233931-t-compiler/major%20changes/topic/Moving%20%60%23%5Bcfg%28test%29%5D%60%20modules%20into%20a%20sepa%E2%80%A6%20compiler-team%23344/near/208220164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/233931-t-compiler/major-changes/topic/Moving.20.60.23.5Bcfg(test).5D.60.20modules.20into.20a.20sepa.E2.80.A6.20compiler-team.23344.html#208220164">(Aug 27 2020 at 14:00)</a>:</h4>
<p>Proposal is being implemented in <a href="https://github.com/rust-lang/rust/pull/75979">https://github.com/rust-lang/rust/pull/75979</a> (draft state).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>